import Vue from 'vue'
import Router from 'vue-router'
import * as Login from '../service/login'

Vue.use(Router)


var router = new Router({
    routes: [
        {
            path: '/',
            redirect: '/home'
        },
        {
            path: '/home',
            component: resolve => require(['../components/common/Home.vue'], resolve),
            children: [
                {
                    path: '/',
                    component: resolve => require(['../components/page/Index/Index.vue'], resolve)
                },
                {
                    path: '/deviceCenter',
                    component: resolve => require(['../components/page/device/DeviceCenter.vue'], resolve)
                },
                {
                    path: '/addDevice',
                    component:resolve=>require(['../components/page/device/AddDevice.vue'], resolve)
                },
                {
                    path: '/businessDevice',
                    component:resolve=>require(['../components/page/device/DeviceLog.vue'], resolve)
                },
                {
                    path: '/usercenter',
                    component:resolve=>require(['../components/page/user/UserCenter.vue'], resolve)
                },
    
                {
                    path: '/usergroup',
                    component: resolve => require(['../components/page/user/UserGroup.vue'], resolve)
                },
                {
                    path: '/useraudit',
                    component: resolve => require(['../components/page/user/UserAudit.vue'], resolve)
                },
                {
                    path: '/innerorder',
                    component: resolve => require(['../components/page/order/InnerOrder.vue'], resolve)
                },
                {
                    path: '/virtualcoinorder',
                    component: resolve => require(['../components/page/order/VirtualCoinOrder.vue'], resolve)
                },
                {
                    path: '/OperationCenter',
                    component: resolve => require(['../components/page/report/OperationCenter.vue'], resolve)
                },
                {
                    path: '/ReportCenter',
                    component: resolve => require(['../components/page/report/ReportCenter.vue'], resolve)
                },
                {
                    path: '/VirtualcoinorderReport',
                    component: resolve => require(['../components/page/report/VirtualcoinorderReport.vue'], resolve)
                },
                {
                    path: '/CashReport',
                    component: resolve => require(['../components/page/report/CashReport.vue'], resolve)
                },
                {
                    path: '/ExchangeRate',
                    component: resolve => require(['../components/page/operation/ExchangeRate.vue'], resolve)
                },
                {
                    path: '/BtmSetting',
                    component: resolve => require(['../components/page/operation/BtmSetting.vue'], resolve)
                },
                {
                    path: '/TradeNumber',
                    component: resolve => require(['../components/page/operation/TradeNumber.vue'], resolve)
                },
                {
                    path: '/NewsCenter',
                    component: resolve => require(['../components/page/operation/NewsCenter.vue'], resolve)
                },
                {
                    path: '/NewsCenter',
                    component: resolve => require(['../components/page/operation/NewsCenter.vue'], resolve)
                },
                {
                    path: '/NewsEdit',
                    component: resolve => require(['../components/page/operation/NewsEdit.vue'], resolve)
                },
                {
                    path: '/AdvCenter',
                    component: resolve => require(['../components/page/operation/AdvCenter.vue'], resolve)
                },
                {
                    path: '/PushMessage',
                    component: resolve => require(['../components/page/operation/PushMessage.vue'], resolve)
                },
                {
                    path: '/SystemSetting',
                    component: resolve => require(['../components/page/operation/SystemSetting.vue'], resolve)
                },
                {
                    path: '/logcenter',
                    component: resolve => require(['../components/page/log/LogCenter.vue'], resolve)
                },
                {
                    path: '/BTMupdateLogCenter',
                    component: resolve => require(['../components/page/log/BTMupdateLogCenter.vue'], resolve)
                },
          
                {
                    path: '/authcenter',
                    component: resolve => require(['../components/page/auth/AuthCenter.vue'], resolve)
                },
                {
                    path:'/authmenu',
                    component:resolve => require(['../components/page/auth/AuthMenu.vue'],resolve)
                },
                {
                    path: '/SubAuthCenter',
                    component: resolve => require(['../components/page/auth/SubAuthCenter.vue'], resolve)
                },
                {
                    path: '/ModifyPwd',
                    component:resolve=>require(['../components/page/modifyPwd.vue'],resolve)
                },
                {
                    path: '/Authdetail',
                    component: resolve => require(['../components/page/auth/AuthDetail.vue'], resolve)
                },
                {
                    path: '/Authalarm',
                    component: resolve => require(['../components/page/auth/Authalarm.vue'],resolve)
                },
                {
                    path: '/deviceAlarms',
                    component: resolve => require(['../components/page/device/DeviceAlarms.vue'],resolve)
                },
                {
                    path: '/Transaction',
                    component: resolve => require(['../components/page/report/Transaction.vue'],resolve)
                },
                {
                    path: '/TurnOutIn',
                    component: resolve => require(['../components/page/report/TurnOutIn.vue'],resolve)
                },
                {
                    path: '/Feestatistics',
                    component: resolve => require(['../components/page/report/Feestatistics.vue'],resolve)
                },
                {
                    path: '/Moneybox',
                    component: resolve => require(['../components/page/report/Moneybox.vue'],resolve)
                },
                // {
                //     path: '/teamset',
                //     component: resolve => require(['../components/page/TeamCenter.vue'], resolve)
                // },
                // {
                //     path: '/teamedit/:groupdId',
                //     component: resolve => require(['../components/page/GroupEdit.vue'], resolve)
                // },
                // {
                //     path: '/owebanner',
                //     component: resolve => require(['../components/page/OweBanner.vue'], resolve)
                // },
                // {
                //     path: '/owemember',
                //     component: resolve => require(['../components/page/OweMember.vue'], resolve)
                // },
                // {
                //     path: '/addmember',
                //     component: resolve => require(['../components/page/MemberEdit.vue'], resolve)
                // },
                // {
                //     path: '/memberedit/:memberId',
                //     component: resolve => require(['../components/page/MemberEdit.vue'], resolve)
                // },
                // {
                //     path: '/skillcenter',
                //     component: resolve => require(['../components/page/OweSkill.vue'], resolve)
                // }
                // {
                //     path: '/upload',
                //     component: resolve => require(['../components/page/Upload.vue'], resolve)       // Vue-Core-Image-Upload组件
                // },
                // {
                //     path: '/basecharts',
                //     component: resolve => require(['../components/page/BaseCharts.vue'], resolve)   // vue-schart组件
                // },
                // {
                //     path: '/drag',
                //     component: resolve => require(['../components/page/DragList.vue'], resolve)    // 拖拽列表组件
                // }
            ]
        },
        {
            path: '/login',
            component: resolve => require(['../components/page/Login.vue'], resolve)
        },
    ]
})
router.beforeEach((from, to, next) => {
    if (from.fullPath != '/login') {
        Login.setLoginPath(from.fullPath)
        if (!Login.checkLogin()) {
            router.push("/login")
            // next({
            //     path: '/login'
            // })
        }
    }
    next()
})


export default router